package com.hetao.simple;

import com.hetao.IPhone;
import com.hetao.Xiaomi;
import com.hetao.Phone;
import com.hetao.HuaWei;

/**
 * Created by hetao on 2018/3/12.
 * 从工厂直接获取产品
 */
public class SimpleFactory {
    public Phone getPhone(String name){
        if("Xiaomi".endsWith(name)){
            return new Xiaomi();
        }else if("HuaWei".endsWith(name)){
            return new HuaWei();
        }else if("iphone".endsWith(name)){
            return new IPhone();
        }
        return null;
    }
}
